class UsersController <  ApplicationController

  active_scaffold :user do |config|
    config.label = " Pracownicy"

    config.columns = [:name, :first_name, :last_name, :phone_number,
                      :login, :password, :password_confirmation, :email_address, :roles]

    config.columns[:roles].form_ui  = :select

    config.columns[:login].description = "(Nazwa która będzie używana do zalgowania się do systemu)"
    config.columns[:login].label = "Login"

    config.columns[:name].label = "Imię i Nazwisko"
    config.columns[:roles].label = "Stanowisko"


    config.columns[:password].label = "Hasło"
    config.columns[:password].description = "(Hasło które będzie używane do zalgowania się do systemu)"
    config.columns[:password_confirmation].label = "Powtórz hasło"

    config.columns[:password].form_ui  = :password
    config.columns[:password_confirmation].form_ui  = :password

    config.columns[:first_name].label = "Imię"
    config.columns[:first_name].description  = "(Imię pracownika)"
    config.columns[:last_name].label = "Nazwisko"
    config.columns[:last_name].description  = "(Nazwisko pracownika)"


    config.columns[:email_address].label = "Adres email"
    config.columns[:email_address].description  = "(Adres email pracownika)"
    config.columns[:phone_number].label = "Telefon"

    config.create.columns.exclude :id, :name
    config.update.columns.exclude :id, :name
    config.show.columns.exclude :id
    config.list.columns.exclude :first_name, :last_name, :password, :password_confirmation, :phone_number
    config.subform.columns = [:first_name, :last_name, :login, :password, :password_confirmation]

    config.list.sorting = {:login => 'ASC'}

    config.create.columns.exclude(:first_name, :last_name, :phone_number)
    config.create.columns.add_subgroup "Dane Personalne" do |group|
      group.add(:first_name, :last_name, :phone_number)
      list.per_page = 15
    end
  end

  def after_create_save(record)
    flash[:info] = 'Pracownik został dodany'
  end

  def after_update_save(record)
    flash[:info] = 'Dane pracownika zostały zmienione'
  end

end

#class UsersController < ApplicationController
#  def new
#    @user = User.new
#  end
#
#  def create
#    @user = User.new(params[:user])
#    if @user.save
#      flash[:notice] = "Registration successful."
#      redirect_to root_url
#    else
#      render :action => 'new'
#    end
#  end
#
#  def edit
#    @user = current_user
#  end
#
#  def update
#    @user = current_user
#    if @user.update_attributes(params[:user])
#      flash[:notice] = "Successfully updated profile."
#      redirect_to root_url
#    else
#      render :action => 'edit'
#    end
#  end
#end
